Skip to content

ENH: Provide dict object for to_dict() #16122 #16220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 16, 2017

Conversation

dwkenefick
Copy link
Contributor

@dwkenefick
Copy link
Contributor Author

Hey all,

I've implemented this for pd.Series.to_dict() and pd.DataFrame.to_dict(). A few notes:

  • I used the into keyword.
  • For the into keyword, I check if the supplied class is a subclass of collections.Mapping.
  • I had to do a few inelegant things to accommodate collections.defaultdict, since it takes it values differently than the other mappings in collections. We can remove this, but it felt odd to support the other collections mappings but not defaultdict. For now, if the user supplies defaultdict to into, the function returns a defaultdict with None for a default_factory. This is all in the docstring.
  • This is marked for the v0.21.0 milestone, but I added it to the “whats new” for v0.20.0.

Let me know if any of the above should change.

@TomAugspurger
Copy link
Contributor

TomAugspurger commented May 3, 2017

I haven't looked closely yet, but for the defaultdict stuff, do are you expecting an initialized defaultdict? i.e.

df.to_dict(into=defaultdict)

or

df.to_dict(into=defaultdict(list))

I would only support the second.

This is marked for the v0.21.0 milestone, but I added it to the “whats new” for v0.20.0.

There should be a 0.20.1 whatsnew. You can add it there since it's backwards-compatible.

"""
# GH16122
if not issubclass(into, collections.Mapping):
Copy link
Contributor

@TomAugspurger TomAugspurger May 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could do something like

import inspect


if not inspect.isclass(into):
    t = type(into)
else:
    t = into

if not issubclass(t, collections.Mapping):
    raise(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I implemented something like this in core.common.

if issubclass(into, collections.Mapping):
if into == collections.defaultdict:
return into(None, compat.iteritems(self))
else:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this and the code in frame into a helper function to avoid duplication
u can put this is core.common

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -18,44 +19,48 @@ def test_to_dict(self):
'A': {'1': 1, '2': 2},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be better as a paramterization

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

tm.assert_series_equal(Series(self.ts.to_dict(), name='ts'), self.ts)
# GH16122
test_maps = (
dict, collections.defaultdict, collections.OrderedDict)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

- ``DataFrame.style.bar()`` now accepts two more options to further customize the bar chart. Bar alignment is set with ``align='left'|'mid'|'zero'``, the default is "left", which is backward compatible; You can now pass a list of ``color=[color_negative, color_positive]``. (:issue:`14757`)

- ``Series.to_dict()`` and ``DataFrame.to_dict()`` now support an ``into`` keyword which allows you to specify the ``collections.Mapping`` subclass that you would like returned. The default is ``dict``, which is backwards compatible. (:issue:`16122`)
Copy link
Contributor

@jreback jreback May 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.21.0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to doc/source/whatsnew/v0.20.1.txt

@codecov
Copy link

codecov bot commented May 3, 2017

Codecov Report

Merging #16220 into master will decrease coverage by <.01%.
The diff coverage is 88.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16220      +/-   ##
==========================================
- Coverage   90.86%   90.86%   -0.01%     
==========================================
  Files         162      162              
  Lines       50887    50895       +8     
==========================================
+ Hits        46240    46247       +7     
- Misses       4647     4648       +1
Flag Coverage Δ
#multiple 88.65% <88.23%> (-0.01%) ⬇️
#single 40.3% <17.64%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/series.py 94.92% <85.71%> (-0.08%) ⬇️
pandas/core/frame.py 97.54% <90%> (-0.05%) ⬇️
pandas/core/common.py 91.03% <0%> (+0.34%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 02eafaf...9d5c8d2. Read the comment docs.

@codecov
Copy link

codecov bot commented May 3, 2017

Codecov Report

Merging #16220 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16220      +/-   ##
==========================================
- Coverage   90.38%   90.37%   -0.02%     
==========================================
  Files         161      161              
  Lines       50916    50930      +14     
==========================================
+ Hits        46021    46026       +5     
- Misses       4895     4904       +9
Flag Coverage Δ
#multiple 88.14% <100%> (ø) ⬆️
#single 40.21% <21.73%> (-0.12%) ⬇️
Impacted Files Coverage Δ
pandas/core/frame.py 97.69% <100%> (-0.1%) ⬇️
pandas/core/common.py 91.39% <100%> (+0.35%) ⬆️
pandas/core/series.py 94.71% <100%> (ø) ⬆️
pandas/io/gbq.py 25% <0%> (-58.34%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4bdbcb6...8469977. Read the comment docs.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks pretty good. some minor changes.

@@ -515,7 +515,6 @@ Other Enhancements
- Options added to allow one to turn on/off using ``bottleneck`` and ``numexpr``, see :ref:`here <basics.accelerate>` (:issue:`16157`)
- ``DataFrame.style.bar()`` now accepts two more options to further customize the bar chart. Bar alignment is set with ``align='left'|'mid'|'zero'``, the default is "left", which is backward compatible; You can now pass a list of ``color=[color_negative, color_positive]``. (:issue:`14757`)


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reset this file

the desired Mapping.

"""
if not inspect.isclass(into):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if its not a class, then you just look at the class itself, it doesn't matter if its empty. this should return a class only.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I wrote it this way is because I imagined someone might pass a pre-populated mapping to this function and expect the series or frame to be appended to what was already in the passed mapping. The error was to make it explicit that this would not happen.

Also happy to simplify this function a little - I'll remove this logic if you don't think its worth checking an empty mapping.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are defining the interface here; this is an internal function, so it should do one thing and ideally have a limited input set. This is just determining if its a valid mapping, no need to get complicated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I would remove this check. This function should just be to ensure that we have an instance that's satisfies the Mapping interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all makes sense - I've reworked the function. It now only returns a class or a partial (if a defaultdict is passed)

if len(into) > 0:
raise ValueError(
"to_dict() only accepts empty mappings.")
elif type(into) == collections.defaultdict:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use isinstance

elif type(into) == collections.defaultdict:
return partial(
collections.defaultdict, into.default_factory)
else:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh? what is this trying to do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the return partial(...) part, I'm trying to get around the way defaultdict accepts arguments. The other out-of-the-box mappings will happily accept only an iterator, which is what both of the to_dict() functions supply to the return value of this function. defaultdict also needs a default_factory, so I use partial to include the default_factory so the to_dict() functions can supply only an iterator.

For the last else, I'm just sending the class of the supplied mapping (once its been confirmed empty) back to the function to avoid duplicated logic.

If you think a different structure works better, or it should be broken up into multiple functions, let me know.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok the defaultdict handling is fine (use isinstance(type, collections.defaultdict) though)

Copy link
Contributor

@jreback jreback May 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I see. the problem is you need to accept instances to deal with defaultdict, so you can now be passed an instance of defaultdict OR a class of something else (or even a class of defaultdict which is an error).

hmm. I would right off the bat detect an instance of a default dict, else only allow a mapping ABC (ex-defaultdict). Then I think you are good, no? (IOW else you would raise).

@@ -479,6 +481,43 @@ def _dict_compat(d):
for key, value in iteritems(d))


def _standardize_mapping(into):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't need to be leading underscore, this is a private module. do you have a more informative name? (longer is ok).

"""
Helper function to standardize the supplied mapping so it can
be passed to the ``Series.to_dict()`` and ``DataFrame.to_dict()``

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a versionadded

instance of the mapping type you want. If you want a
collections.defaultdict, you must pass an initialized
instance.
.. versionadded:: 0.21.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line

Returns
-------
result : dict like {column -> {index -> value}}
result : collections.Mapping like {column -> {index -> value}}
If ``into`` is collections.defaultdict, the return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add some examples of using this.

object. Can be the actual class or an empty
instance of the mapping type you want. If you want a
collections.defaultdict, you must pass an initialized
.. versionadded:: 0.21.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more comments. but lgtm.

Parameters
----------
into : instance or subclass of collections.Mapping
The argument supplied to ``to_dict``. Must be a class, an
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove references to to_dict, this is generic about mappings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, though you can add a See Also section to point to to_dict. You can also remove references to to_dict in the summary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the references and added a See Also section.

@@ -479,6 +481,45 @@ def _dict_compat(d):
for key, value in iteritems(d))


def prep_maping_for_to_dict(into):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe standarize_dict_like_mapping

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even just standardize_mapping

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to standardize_mapping

elif into == collections.defaultdict:
raise TypeError(
'to_dict() only accepts initialized defaultdicts')
else:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just return into here, no need for the else.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

elif isinstance(into, collections.defaultdict):
return partial(
collections.defaultdict, into.default_factory)
else:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need the else (just return the partial)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

>>> df.to_dict(into=OrderedDict)
OrderedDict([('col2', OrderedDict([('a', 0.5), ('b', 0.75)])),
('col1', OrderedDict([('a', 1), ('b', 2)]))])
>>> dd = defaultdict(list)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice examples!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a blank line and a preamble to this example


>>> df.to_dict(into=OrderedDict)
OrderedDict([('col2', OrderedDict([('a', 0.5), ('b', 0.75)])),
('col1', OrderedDict([('a', 1), ('b', 2)]))])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the output of this example correct? (I mean: is it what you actually get with the PR?)
As I think if you specify an OrderedDict, I would also expect to get the result in the correct order, which means col1, col2 (not col2, col1)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I messed this up when writing the example - I switched the column order in-between writing these tests. This should be fixed now.

Copy link
Contributor

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This look pretty close @dwkenefick. Just a few changes.

@@ -479,6 +481,45 @@ def _dict_compat(d):
for key, value in iteritems(d))


def prep_maping_for_to_dict(into):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even just standardize_mapping

Parameters
----------
into : instance or subclass of collections.Mapping
The argument supplied to ``to_dict``. Must be a class, an
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, though you can add a See Also section to point to to_dict. You can also remove references to to_dict in the summary.

the desired Mapping.

"""
if not inspect.isclass(into):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I would remove this check. This function should just be to ensure that we have an instance that's satisfies the Mapping interface.

for row in self.values]
elif orient.lower().startswith('i'):
return dict((k, v.to_dict()) for k, v in self.iterrows())
return into_c((k, v.to_dict(into)) for k, v in self.iterrows())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it correct to use into here? What if the user passed an instance rather than a class? Wouldn't the values all be written into the same object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is correct. v.to_dict(into) should call standardize_mapping again. Since standardize_mapping only returns a class, I don't think there is a danger of populating the same object twice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha.nI forgot that standardize_mapping always returned a class

dict,
collections.defaultdict(list),
collections.OrderedDict])
def test_to_dict(self, mapping):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be tested elsewhere, but can you add a test with a dataframe that has duplicate columns? Make sure to catch the warning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done - I added one at the end. Let me know if that is what you were getting at.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor typos & another test, otherwise lgtm. ping on green.

def standardize_mapping(into):
"""
Helper function to standardize a supplied mapping.
.. versionadded:: 0.21.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs a blank line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

----------
into : instance or subclass of collections.Mapping
Must be a class, an initialized collections.defaultdict,
or an empty instance of a collections.Mapping subclass.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this last statement is true, it doesn't have to be empty (nor should we require it)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed "empty," which should make this correct.

The collections.Mapping subclass to use as the return
object. Can be the actual class or an empty
instance of the mapping type you want. If you want a
collections.defaultdict, you must pass an initialized
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you must pass it initialized. (maybe elsewhere as well)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed here and in frame.py

comp_data['duped'] = comp_data[df.columns[0]]
for k, v in compat.iteritems(comp_data):
for k2, v2 in compat.iteritems(v):
assert (v2 == recons_data[k2][k])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also add a test that hits some of the errors people might encounter (you do check these in the testing of standardize_mapping), but this is an integration test. you can put a test right after this, maybe test_to_dict_errors

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this test - made sure the TypeErrors were caught. Let me know if you think anything else should go in there.

@jreback jreback added this to the 0.21.0 milestone May 11, 2017
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few more comments on the docs


Examples
--------
>>> from pandas import DataFrame
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove this import, but use pd.DataFrame instead of DataFrame in the other places

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Examples
--------
>>> from pandas import DataFrame
>>> from collections import OrderedDict, defaultdict
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this import to the example where it is used?

"""
Convert Series to {label -> value} dict
Convert Series to {label -> value} dict or dict-like object
Parameters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line between the first line and Parameters

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


Examples
--------
>>> from pandas import Series
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment here as for DataFrame (leave out the import, and use pd.Series instead for consistency within the docstrings)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

result : dict like {column -> {index -> value}}
result : collections.Mapping like {column -> {index -> value}}
If ``into`` is collections.defaultdict, the return
value's default_factory will be None.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand this one. It seems to contrast with what is said above about a defaultdict needing to be initialized. So in that case, the default_factory will just be what is provided in the initialized defaultdict? (and which can be None, if you didn't provide a default_factory, but that seems a bit besides the point to mention here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is from an earlier version, and I forgot to update the docs. This sentence is wrong, and its gone now.

@TomAugspurger
Copy link
Contributor

@jreback look good to you? Your requested changes were around standardize_mapping, and I think they were all addressed.

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates!
Some minor extra comments

return dict(compat.iteritems(self))
value_dict : collections.Mapping
If ``into`` is collections.defaultdict, the return
value's default_factory will be None.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed as well I think (you updated it for the DataFrame docstring)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

{'a': {'col1': 1.0, 'col2': 0.5}, 'b': {'col1': 2.0, 'col2': 0.75}}

You can also specify the mapping type.
>>> from collections import OrderedDict, defaultdict
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put a blank line between the two lines above?
(sorry for all these small comments, but sphinx / rst is quite nitpickly when it comes to whitespace, in order to render correctly in the html online documentation)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem. These are easy.

@jreback
Copy link
Contributor

jreback commented May 15, 2017

lgtm. I think @jorisvandenbossche had a couple of small changes.

@TomAugspurger TomAugspurger merged commit f040ed2 into pandas-dev:master May 16, 2017
@TomAugspurger
Copy link
Contributor

The appveyor build finished: https://ci.appveyor.com/project/pandas-dev/pandas/build/1.0.1881 Not sure why it hasn't reported that it's done.

Thanks @dwkenefick, nice work!

pawroman added a commit to pawroman/pandas that referenced this pull request May 18, 2017
* upstream/master: (48 commits)
  BUG: Categorical comparison with unordered (pandas-dev#16339)
  ENH: Adding 'protocol' parameter to 'to_pickle'.
  PERF: improve MultiIndex get_loc performance (pandas-dev#16346)
  TST: remove pandas-datareader xfail as 0.4.0 works (pandas-dev#16374)
  TST: followup to pandas-dev#16364, catch errstate warnings (pandas-dev#16373)
  DOC: new oauth token
  TST: Add test for clip-na (pandas-dev#16369)
  ENH: Draft metadata specification doc for Apache Parquet (pandas-dev#16315)
  MAINT: Add .iml to .gitignore (pandas-dev#16368)
  BUG/API: Categorical constructor scalar categories (pandas-dev#16340)
  ENH: Provide dict object for to_dict() pandas-dev#16122 (pandas-dev#16220)
  PERF: improved clip performance (pandas-dev#16364)
  DOC: try new token for docs
  DOC: try with new secure token
  DOC: add developer section to the docs
  DEPS: Drop Python 3.4 support (pandas-dev#16303)
  DOC: remove credential helper
  DOC: force fetch on build docs
  DOC: redo dev docs access token
  DOC: add dataframe construction in merge_asof example (pandas-dev#16348)
  ...
pcluo pushed a commit to pcluo/pandas that referenced this pull request May 22, 2017
…6220)

* ENH: Provide dict object for to_dict() pandas-dev#16122

* ENH: Provide dict object for to_dict() pandas-dev#16122

* ENH: Provide dict object for to_dict() pandas-dev#16122

* ENH: Provide dict object for to_dict() pandas-dev#16122

* ENH: Provide dict object for to_dict() pandas-dev#16122

* ENH: Provide dict object for to_dict() pandas-dev#16122

* ENH: Provide dict object for to_dict() pandas-dev#16122
stangirala pushed a commit to stangirala/pandas that referenced this pull request Jun 11, 2017
…6220)

* ENH: Provide dict object for to_dict() pandas-dev#16122

* ENH: Provide dict object for to_dict() pandas-dev#16122

* ENH: Provide dict object for to_dict() pandas-dev#16122

* ENH: Provide dict object for to_dict() pandas-dev#16122

* ENH: Provide dict object for to_dict() pandas-dev#16122

* ENH: Provide dict object for to_dict() pandas-dev#16122

* ENH: Provide dict object for to_dict() pandas-dev#16122
>>> df
col1 col2
a 1 0.1
b 2 0.2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 0.1 and 0.2 are wrong, should be 0.5 and 0.75

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Provide dict object for pd.Series.to_dict()
5 participants